<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title a m-cf"><{$tit}>列表</div>
                </div>
                <div class="am-tabs am-margin-bottom">
                    <{tabTit1($tabtit)}>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <{include file='admin/public/toolbar.php'}>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>
                                    <label class="am-checkbox-inline">
                                        <input type="checkbox" id="checkedAllBtn" data-am-ucheck />
                                        ID
                                    </label>
                                </th>
                                <th>角色</th>
                                <th>用户名</th>
                                <th>姓名</th>
                                <th>手机</th>
                                <th>微信用户</th>
                                <th>添加时间</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if ($list): foreach ($list as $val): ?>
                                <tr>
                                    <td class="am-text-middle">
                                        <label class="am-checkbox-inline">
                                            <input type="checkbox" name="opid[]" value="<?= $val['id'] ?>" data-am-ucheck />
                                            <?= $val['id'] ?>
                                        </label>
                                    </td>
                                    <td class="am-text-middle"><?= $roles[$val['role_id']]['name'] ?></td>
                                    <td class="am-text-middle"><?= $val['username'] ?></td>
                                    <td class="am-text-middle"><?= $val['realname'] ?></td>
                                    <td class="am-text-middle"><?= $val['tel'] ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">

                                            <?php if (checkPrivilege('user/recharge')): ?>
                                                <a class="j-recharge tpl-table-black-operation-green"
                                                   href="javascript:void(0);"
                                                   title="微信绑定"
                                                   data-id="<?= $val['id'] ?>"
                                                   data-realname="<?= $val['realname'] ?>"
                                                >
                                                    <i class="iconfont icon-weixin"></i>
                                                    绑定
                                                </a>
                                            <?php endif; ?>
                                            <?= $users[$val['user_id']]['nickName'] ?>
                                        </div>
                                    </td>
                                    <td class="am-text-middle"><?= $val['add_time'] ?></td>
                                    <td class="am-text-middle">
                                        <{include file=$m.'/public/act.php'}>
                                    </td>
                                    <td class="am-text-middle">
                                        <{include file=$m.'/public/auth.php'}>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="8" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <{$showPage nofilter}>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- 模板：用户充值 -->
<script id="tpl-recharge" type="text/template">
    <div class="am-padding-xs am-padding-top-sm">
        <form class="am-form tpl-form-line-form" method="post" action="">
            <div class="j-tabs am-tabs">
                <!-- <ul class="am-tabs-nav am-nav am-nav-tabs">
                    <li class="am-active"><a href="#tab1">充值余额</a></li>
                    <li><a href="#tab2">充值积分</a></li>
                </ul> -->
                <div class="am-tabs-bd am-padding-xs">
                    <div class="am-tab-panel am-padding-0 am-active" id="tab1">
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                姓名
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <div class="am-form--static">{{ realname }}</div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                手机号
                            </label>
                            <div class="am-u-sm-8 am-u-end">
                                <input type="number" min="0" class="tpl-form-input"
                                       placeholder="请输入手机号" name="wxbind[tel]" value="" required>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </div>
</script>

<script>
    $(function () {

        /**
         * 账户充值
         */
        $('.j-recharge').on('click', function () {
            var $tabs, data = $(this).data();
            $.showModal({
                title: '微信绑定'
                , area: '460px'
                , content: template('tpl-recharge', data)
                , uCheck: true
                , success: function ($content) {
                    $tabs = $content.find('.j-tabs');
                    $tabs.tabs({noSwipe: 1});
                }
                , yes: function ($content) {
                    $content.find('form').myAjaxSubmit({
                        url: '/<{$routeUrl}>/wxbind',
                        data: {
                            id: data.id,
                            source: $tabs.data('amui.tabs').activeIndex
                        }
                    });
                    return true;
                }
            });
        });

        /**
         * 账户充值
         */
        $('.j-auth').on('click', function () {
            var data = $(this).data();
            $.showModal({
                title: '用户授权'
                , area: '460px'
                , content: template('tpl-recharge', data)
                , uCheck: true
                , success: function ($content) {
                    // $content.find('.j-tabs').tabs({noSwipe: 1});
                }
                , yes: function ($content) {
                    $content.find('form').myAjaxSubmit({
                        url: '/<{$routeUrl}>/auth',
                        data: {id: data.id}
                    });
                    return true;
                }
            });
        });

        // 审核
        $('.j-act').opid('id', "/<{$routeUrl}>/act");
        // 隐藏
        $('.j-ban').opid('id', "/<{$routeUrl}>/ban");
        // 删除
        $('.j-del').opid('id', "/<{$routeUrl}>/del");

        // 状态
        $('.item-act').act('id', "/<{$routeUrl}>/act");
        // 删除元素
        $('.item-delete').delete('id', "/<{$routeUrl}>/del", '删除后不可恢复，确定要删除吗？');

        // open
        $('.item-auth').open('id', "/<{$routeUrl}>/auth", '授权');

    });
</script>

